<?php echo js('admin/settings.js');?>
<?php echo js('jquery/popupWindow/jquery.popupWindow.js');?>
<script type="text/javascript">
	function delte_pickup_image(){
		$('#pickup_image_holder').html("");
		$('#pickup_image').val("");
	}
	jQuery(function($){
		$('#a_pickup').popupWindow({height:500, width:800, centerBrowser:1}); 
	});
</script>  
<div id="page-heading"><h1><?php echo sprintf(lang('regions.edit_title'), def_lang($region, 'name')) ?></h1></div>
<?php $this->load->view('partials/notices'); ?>
<form method="post" action="<?php echo site_url('admin/catalog/edit_region/'. $region->id);?>" >
		<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
		<tr>
			<th valign="top"><?php echo lang('regions.slug_label'); ?><span class="require">*</span>:</th>
			<td><?php echo form_input('slug', $region->slug, 'class="inp-form"'); ?></td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('regions.region_type'); ?><span class="require">*</span>:</th>
			<td><?php echo form_dropdown('region_type', $region_types, $region->region_type, 'id="region_type" class="select_box"'); ?></td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('regions.channel_id'); ?><span class="require">*</span>:</th>
			<?php 
			$channel_options = array();
			foreach($channels as $channel){
				$channel_options[$channel->id] = empty($channel->name)? lang('global:empty'): $channel->name;
			}
			?>
			<td><?php echo form_dropdown('channel_id', array(0 => lang('global:select-pick')) + $channel_options, $region->channel_id, 'id="channel_id" class="select_box"'); ?></td>
		</tr>
		<tr style="display:none">
			<th valign="top"><?php echo lang('regions.abbreviation'); ?><span class="require">*</span>:</th>
			<td><?php echo form_input('abbreviation', $region->abbreviation, 'class="inp-form"'); ?></td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('regions.parent_label'); ?> <span class="require">*</span>:</th>
			<td><?php echo form_dropdown('parent_id', array(0 => lang('regions.no_subregions')) + $regions_tree, $region->parent_id, 'id="parent_id" class="select_box"'); ?></td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('regions.sort'); ?>:</th>
			<td><?php echo form_input('sort', $region->sort, 'class="inp-form"'); ?></td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('regions.image'); ?>:</th>
			<td>
			<input type="hidden" value="<?php echo $region->image?>" name="image" id="pickup_image"/>
			<a href="<?php echo site_url('admin/folders/pickup_image')?>" id="a_pickup"><img src="<?php echo image_url('admin/shared/icon.png')?>"/></a>
			<div id="pickup_image_holder">
			<?php if(!empty($region->image)):?>
				<a href="javascript:void(0);" onclick="delte_pickup_image()"><img src="<?php echo site_url('files/thumb/' . $region->image . '/64/64?'. rand(0, 99)); ?>" title="click to delete"/></a>
			<?php endif;?>
			</div>
			</td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('regions.link'); ?>:</th>
			<td><?php echo form_input('link', $region->link, 'class="inp-form"'); ?></td>
		</tr>
</table>		
<table border="0" cellpadding="0" cellspacing="0"  id="id-form" style="width:100%;">
		<tr>
			<th colspan="3">
			<div id="usual-tab" class="usual-tab">
				<ul class="idTabs"> 
					<?php foreach($supported_languages as $lang => $content): ?>
						<li><a href="#<?php echo $lang;?>"><span style="font-weight: bold; font-size:12px;"><?php echo $content['name'];?></span></a></li>
					<?php endforeach; ?>
				</ul>
				<?php foreach($supported_languages as $lang => $content): ?>
					<div id="<?php echo $lang;?>" class="lang_content">
						<fieldset>
							<table border="0" cellpadding="0" cellspacing="0"  id="id-form" style="width:100%;">
							<tr>
								<th valign="top"><?php echo lang('regions.name_label'); ?><span class="require">*</span>:</th>
								<td><?php echo form_input('name_'. $lang, def_lang($region, 'name', $lang), 'class="inp-form"'); ?></td>
							</tr>
							</table>
						</fieldset>	
					</div> 
				<?php endforeach; ?> 
			</div> 
			</th>
		</tr>
	<tr>
		<th>&nbsp;</th>
		<td valign="top">
			<input type="submit" value="" class="form-submit" />
			<input type="reset" value="" class="form-reset"  />
		</td>
		<td></td>
	</tr>
	</table>
	<input type="hidden" name="id" value="<?php echo $region->id?>"/>
</form>	
